
<template>
  <div class="app_menu">
    <el-menu mode="vertical"
             background-color="#545c64"
             text-color="#fff"
             :collapse="$store.state.menuColl"
             :router="true"
             @select="nowMenu"
             ref="mymenu"
             :default-active="$store.state.defAct">
      <el-menu-item :route='{name:"Home"}'
                    index="">首页</el-menu-item>
      <el-submenu index="用户管理">
        <template slot="title">
          <i class="el-icon-location"></i>
          <span>用户管理</span>
        </template>
        <el-menu-item :disabled="$store.state.userInfo.power=='2'"
                      :route='{name:"admin"}'
                      index="管理员">管理员</el-menu-item>
        <el-menu-item :disabled="$store.state.userInfo.power=='2'"
                      :route='{name:"student"}'
                      index="学员管理">学员管理</el-menu-item>
      </el-submenu>
      <el-submenu index="课程管理">
        <template slot="title">
          <div>
            <i class="el-icon-lock"></i>
            <span>课程管理</span>
          </div>
        </template>
        <el-menu-item :route="{name:'courseadd'}"
                      index="课程添加">课程添加</el-menu-item>
        <el-menu-item :route="{name:'courseList'}"
                      index="课程列表">课程列表</el-menu-item>
        <el-menu-item :route="{name:'video'}"
                      index="视频模块">视频模块</el-menu-item>
      </el-submenu>
    </el-menu>
  </div>
</template>
<script>
import { mapMutations } from 'vuex'
export default {
  data () {
    return {

    }
  },
  beforeMount () {
  },
  mounted () {
    console.log(this.$store.state.defAct)
  },
  methods: {
    ...mapMutations(["changeData"]),
    nowMenu (val, indexPath) {
      // 当前打开的菜单的index
      console.log(9999999)
      // console.log(val, indexPath) //val=admin
      this.changeData(indexPath)//['用户管理', '管理员']
      // 改变当前激活的导航

      this.$store.commit("changedefAct", indexPath[1])
    }
  }
}
</script>
<style lang="less">
</style>